VERSION 5.00
Begin VB.Form frmDeleteUsr 
   Caption         =   "Delete User"
   ClientHeight    =   5310
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6645
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   5310
   ScaleWidth      =   6645
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton Command2 
      Caption         =   "Close"
      Height          =   615
      Left            =   3960
      TabIndex        =   3
      Top             =   4200
      Width           =   2295
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "Delete Selected"
      Height          =   615
      Left            =   360
      TabIndex        =   2
      Top             =   4200
      Width           =   2295
   End
   Begin VB.ListBox lstUsers 
      Height          =   2985
      Left            =   360
      MultiSelect     =   2  'Extended
      TabIndex        =   1
      Top             =   840
      Width           =   5895
   End
   Begin VB.Label lblUsers 
      AutoSize        =   -1  'True
      Caption         =   "List of users"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   1560
   End
End
Attribute VB_Name = "frmDeleteUsr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdDelete_Click()
    Dim connector As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    connector.CursorLocation = adUseClient
    connector.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
    & "SERVER=127.0.0.1;" _
    & "DATABASE=incidences;" _
    & "UID=root;" _
    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    connector.Open
    rs.ActiveConnection = connector
    rs.CursorType = adOpenDynamic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockOptimistic
    For i = Me.lstUsers.ListCount - 1 To 0 Step -1
        If Me.lstUsers.Selected(i) = True Then
            rs.Open ("delete from users where Login='" & Me.lstUsers.List(i) & "'")
            Me.lstUsers.RemoveItem (i)
        End If
    Next i
    MsgBox ("DONE")
End Sub

Private Sub Command2_Click()
    Me.Hide
End Sub

Private Sub Form_Load()
    Me.lstUsers.Clear
    Dim connector As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    connector.CursorLocation = adUseClient
    connector.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
    & "SERVER=127.0.0.1;" _
    & "DATABASE=incidences;" _
    & "UID=root;" _
    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    connector.Open
    rs.ActiveConnection = connector
    rs.CursorType = adOpenDynamic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockOptimistic
    rs.Open ("select login from users")
    While Not rs.EOF
        Me.lstUsers.AddItem (rs.Fields(0).Value)
        rs.MoveNext
    Wend
End Sub
